package com.duoduo.demo.springnoxml.rabbitmq;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Rabbitmq接收器
 * <p>
 * https://www.jianshu.com/p/e1258c004314
 * </p>
 * @author chengesheng@kedacom.com
 * @date 2018年3月14日下午4:06:45
 */
@Component
public class RabbitmqReceiver {

	@Value("${app.rabbitmq.queue1}")
	private String queueName1;
	@Value("${app.rabbitmq.queue2}")
	private String queueName2;

	@RabbitListener(queues = "${app.rabbitmq.queue1}")
	public String processMessage1(String msg) {
		System.out.println(Thread.currentThread().getName() + " 接收到来自" + queueName1 + "队列的消息：" + msg);
		return msg;
	}

	@RabbitListener(queues = "${app.rabbitmq.queue2}")
	public void processMessage2(String msg) {
		System.out.println(Thread.currentThread().getName() + " 接收到来自" + queueName2 + "队列的消息：" + msg);
	}
}
